﻿Public Class Tools

    Friend Shared Function CheckIfFileExist(ByVal aFile As String) As Boolean
        Return System.IO.File.Exists(aFile)
    End Function

    Friend Shared Function AppendPath(ByVal aPath As String, ByVal aDiretory As String) As String
        Dim myAppendDir As String = aDiretory
        If aDiretory.StartsWith("\"c) Then
            myAppendDir = aDiretory.Substring(1)
        End If
        Dim myPath As String = Nothing
        If aPath.EndsWith("\") Then
            myPath = aPath & myAppendDir
        Else
            myPath = aPath & "\" & myAppendDir
        End If
        If Not myPath.EndsWith("\") Then Return myPath
        Return myPath.Substring(0, myPath.Length - 1)
    End Function

    Friend Shared Function CreateFilePath(ByVal aPath As String, ByVal aFilename As String) As String
        'it's exact the same waht we do for appending a path to a directory
        Dim myAppendDir As String = aFilename
        If aFilename.StartsWith("\"c) Then
            myAppendDir = aFilename.Substring(1)
        End If
        Dim myPath As String = Nothing
        If aPath.EndsWith("\") Then
            myPath = aPath & myAppendDir
        Else
            myPath = aPath & "\" & myAppendDir
        End If
        If Not myPath.EndsWith("\") Then Return myPath
        Return myPath.Substring(0, myPath.Length - 1)
    End Function

End Class
